import java.util.ArrayDeque;
import java.util.Stack;

public class myQueueUseStack {
    //用栈实现队列
    public ArrayDeque<Integer> stack1;
    public ArrayDeque<Integer> stack2;
    public myQueueUseStack(){
        stack1=new ArrayDeque<>();
        stack2=new ArrayDeque<>();
    }
    //出栈
    public int poll(){
        if(empty()){
            return -1;
        }
        if(stack2.isEmpty()){
           while (!stack1.isEmpty()){
               stack2.push(stack1.pop());
           }
        }
        return stack2.pop();
    }
    //入栈
    public void offer(int x){
        stack1.push(x);
    }

    //取栈顶元素
    public int peek(){
        if(empty()){
            return -1;
        }
        if(stack2.isEmpty()){
            while (!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.peek();
    }
    //判空
    public boolean empty(){
        return stack1.isEmpty()&&stack2.isEmpty();
    }
}
